"""
@author: liujun
@file: 2022-11-4-数据结构.py
@time: 2022/11/4 10:28
"""
import random
#string类型是不可变数据类型
# >>> str1[1] = "d"
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>

#列表
#有序项目集合
#可以存放任何类型对象
#可变数据类型

#list类型是可变数据类型，内存地址不变
# >>> a[1]=800
# >>> a
# [1, 800, 3, <built-in function print>]

#列表可以进行加法和乘法运算
# >>> [1,2]+[3,4]
# [1, 2, 3, 4]
# >>> [1,2]*2
# [1, 2, 1, 2]

#pop删除并输出返回值
# ['xxx', 'a', 'b', 'c', 'd', [1, 2, 3], 'yy']
# >>> result = a.pop()
# >>> result
# 'yy'

# member = list(range(1,31))
# while len(member) > 16:
#     i = 1
#     while i < 7:
#         member.append(member.pop(0))
#         i+=1
#     print(member.pop(0))

# lst = [2,4,5,3,6,7,9]
# num=int(input("请输入一个整数："))
# for m,i in enumerate(lst):
#     for n,j in enumerate(lst):
#         num2 = int(i)+int(j)
#         if n==m:
#             break
#         elif num == num2 :
#             print(n,m)

#元组
#有序项目集合
#可以存放任何类型对象
#不可变数据类型

#字典
#key-value
# str1 = "asfgoajgboasdjaap31"
# d={}
# for i in str1:
#     d[i] = str1.count(i)
# print(d)
# >>> d4.pop('a')
# 3
# >>> d4
# {'b': 2, 'c': 6, 'd': 5}
# >>> d3.popitem()
# ('admin', {'passwd': 'admin123', 'money': 2000})
# >>> d4.popitem()
# ('d', 5)

#集合（set）
#无序
#集合元素必须是可hash的
#天生去重
#可变数据类型
#集合可以看做一个只有key的字典
people = ['张三', '李四', '王五', '李大雷', '王小美']
a = ['张三', '李四', '王五', '李大雷', '王小美']
c=[]
for i in a:
    a.remove(i)
    b=random.choice(a)
    c.append(b)
    a.remove(b)
    a.append(i)
print("a is:", a)
print("c is:",c)
if people[len(people)-2] in a:
    a.remove(people[len(people)-2])
    c=c+a
    c.append(people[len(people)-2])
elif people[len(people)-1] in a:
    a.remove(people[len(people)-1])
    c.append(people[len(people)-1])
    c=c+a
else:
    c=c+a
print(people)
print(c)


# rest=['张三','李四']#请假休息的人
# e=[]
# with open("lucklist.txt","r",encoding='utf-8') as f:
#     for d in f.readlines():
#         e.append(d.strip('\n'))
# now = list(set(people) - set(rest) - set(e))
# if now==[]:
#     with open("lucklist.txt", "w", encoding='utf-8') as f:
#         f.write("")
#     print("全部抽取过了，请再抽一次")
# else:
#     luck = random.choice(now)
#     print("请",luck,"同学来回答问题")
#     with open("lucklist.txt","a",encoding='utf-8') as f:
#         f.write('\n'+luck)

# print("欢迎来到三乐购物系统")
# num = input("请选择1.登录 2.注册：")
# if num == "1":
#     name = input("请输入用户名：")
#     password = input("请输入密码：")
#     with open("message.txt", "r", encoding='utf-8') as f:
#         usr=[]
#         for line in f.readlines():
#             line = line.strip('\n')
#             b=line.split(' ')
#             usr.append(b)
#     usr=dict(usr)
#     if name in usr:
#         r=usr[name].split(',')
#         if password in r:
#             print("登录成功！")
#             print("下面是商品信息")
#             with open("shopping.txt", "r", encoding='utf-8') as f:
#                 shopping = f.read()
#                 print(shopping)
#         else:
#             print("密码错误")
#     else:
#         print("用户名错误")
# elif num == "2":
#     print("现在注册立送100")
#     name = input("请输入你要注册的用户名：")
#     with open("message.txt", "r", encoding='utf-8') as f:
#         usr = []
#         for line in f.readlines():
#             line = line.strip('\n')
#             b = line.split(' ')
#             usr.append(b)
#     usr = dict(usr)
#     if name in usr:
#         print("用户名已存在")
#     else:
#         print("用户名可用")
#         password1 = input("请输入密码：")
#         password2 = input("请再次输入密码：")
#         if password1 == password2:
#             print("恭喜用户创建成功，或得100！")
#             with open("message.txt", "a", encoding='utf-8') as f:
#                 f.write('\n' + name + ' ' + name + ',' + password1 + ',' + '100')
#         else:
#             print("两次密码不一致")